package day16.晚间练习.tcp本地文件上传;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss= null;
        while (true) {
            ss = new ServerSocket(10008);
            Socket accept = ss.accept();
            BufferedInputStream bis=new BufferedInputStream(accept.getInputStream());

            BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("F:\\截图文件\\"+ UUID.randomUUID().toString()+".png"));
            int b ;
            while ( (b=bis.read())!=-1){
                bos.write(b);
            }
            BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
            bw.write("上传成功");
            bw.newLine();
            bw.flush();

            bos.close();
            accept.close();
        }
      //  ss.close();

    }
}
